package com.tarena.lbs.message.web.mq;

import com.tarena.lbs.message.web.mq.source.NoticeMessageOutputSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * 消息通知MQ生产者
 *
 * @since 2021-05-31
 */
@Component
@EnableBinding({NoticeMessageOutputSource.class})
public class NoticeProducer {

    @Autowired
    private NoticeMessageOutputSource noticeMessageOutputSource;

    /**
     * 发送普通消息
     *
     * @param message 要发送的消息
     */
    public void sendMsg(String message) {
        boolean res = noticeMessageOutputSource.output().send(MessageBuilder.withPayload(message).build());
        System.out.println("发消息" + message);
    }
}